package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pojo.user;

@Controller
public class ControllerDemo {
    @RequestMapping(value = "aa",method = {RequestMethod.GET,RequestMethod.POST})
    public String print(){
        System.out.println("出来啦");
        return "first";
    }

    @RequestMapping(value = "asd/{id}/{name}")
    public String print1(@PathVariable("id") int id,@PathVariable("name") String name){
        System.out.println("出来啦");
        return "first";
    }

    @RequestMapping(value = "get/{id}",method = RequestMethod.GET)
    public String get(@PathVariable("id")Integer id){
        System.out.println("id:"+id);
        return "first";
    }
    @RequestMapping(value = "post/{id}",method = RequestMethod.POST)
    public String post(@PathVariable("id")Integer id){
        System.out.println("post:"+id);
        return "first";
    }

    @RequestMapping(value = "/user",method = RequestMethod.POST)
    @ResponseBody
    public String user(user user){
        System.out.println("post:"+user.toString());
        return user.toString();
    }
}
